﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Tag="Layout - ViewBox ControlTemplate with Canvas">
    <UserControl.Resources>
        <ControlTemplate x:Key="CanvasTemplate">
            <Canvas Width="200" Height="150">
                <Path Canvas.Left="10" Canvas.Top="5"
                    Data="F0 M10,100 L100,100 100,50Z"
                    Fill="{TemplateBinding Foreground}"
                    StrokeThickness="1" Stroke="Black"
                    />
                <Path Canvas.Left="50" Canvas.Top="10"
                    Data="F0 M10,100 L100,100 100,50Z"
                    Fill="{TemplateBinding Foreground}"
                    StrokeThickness="1" Stroke="Black"
                    />
            </Canvas>
        </ControlTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Viewbox Grid.Row="0">
            <ContentControl
                Foreground="Red"
                Template="{StaticResource CanvasTemplate}"
                />
        </Viewbox>
        <Viewbox Grid.Row="1"
            Width="48">
            <ContentControl
                Foreground="Blue"
                Template="{StaticResource CanvasTemplate}"
                />
        </Viewbox>
    </Grid>
</UserControl>
